# Maintainer: Jakub Panek <me@panekj.dev>
pkgname=nerdctl
pkgver=1.7.2
pkgrel=0
pkgdesc="Docker-compatible CLI for containerd"
url="https://github.com/containerd/nerdctl/"
arch="all"
license="Apache-2.0"
depends="ca-certificates containerd cni-plugins iptables"
makedepends="go"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/containerd/nerdctl/archive/refs/tags/v$pkgver.tar.gz"
options="!check" # a lot fail

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -ldflags "-X github.com/containerd/nerdctl/pkg/version.Version=$pkgver" \
		-o nerdctl ./cmd/nerdctl

	for shell in bash fish zsh; do
		./nerdctl completion $shell > nerdctl.$shell
	done
}

package() {
	install -Dm755 nerdctl -t "$pkgdir"/usr/bin
	install -Dm644 docs/*.md -t "$pkgdir"/usr/share/doc/$pkgname

	install -Dm644 nerdctl.bash \
		"$pkgdir"/usr/share/bash-completion/completions/nerdctl
	install -Dm644 nerdctl.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/nerdctl.fish
	install -Dm644 nerdctl.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_nerdctl
}

sha512sums="
373583bac9ed6a8440eccb3fcf96db175f140999452c0216acf2837654a6ec237e4f1c4eee024094160198833f20a28e52f008f5f6759dc5dea8d62ce5982c04  nerdctl-1.7.2.tar.gz
"
